<template>
  <el-form :model="formData" label-width="120px" ref="form" v-loading="loading" class="pr-4">
    <el-form-item label="物料编码" prop="fnumber">
  <el-input v-model="formData.fnumber" name="fnumber" clearable />
</el-form-item>
<el-form-item label="物料名称" prop="fname">
  <el-input v-model="formData.fname" name="fname" clearable />
</el-form-item>
<el-form-item label="物料规格" prop="fspecification">
  <el-input v-model="formData.fspecification" name="fspecification" clearable />
</el-form-item>
<el-form-item label="单位编码" prop="funit_number">
  <el-radio-group v-model="formData.funit_number">
    <el-radio v-for="item in options" :key="item.value" :label="item.value" name="funit_number">{{ item.label }}</el-radio>
  </el-radio-group>
</el-form-item>
<el-form-item label="单位名称" prop="funit_name">
  <el-input v-model="formData.funit_name" name="funit_name" clearable />
</el-form-item>
<el-form-item label="组织名称" prop="fuseorgid_name">
  <el-input v-model="formData.fuseorgid_name" name="fuseorgid_name" clearable />
</el-form-item>
<el-form-item label="分类编码" prop="fbaseproperty_number">
  <el-input v-model="formData.fbaseproperty_number" name="fbaseproperty_number" clearable />
</el-form-item>
<el-form-item label="分类名称" prop="fbaseproperty_name">
  <el-input v-model="formData.fbaseproperty_name" name="fbaseproperty_name" clearable />
</el-form-item>
<el-form-item label="数据状态" prop="fdocumentstatus">
  <el-input v-model="formData.fdocumentstatus" name="fdocumentstatus" clearable />
</el-form-item>
<el-form-item label="禁用状态" prop="fforbidstatus">
  <el-input v-model="formData.fforbidstatus" name="fforbidstatus" clearable />
</el-form-item>
<el-form-item label="是否启用箱号" prop="fcasecode">
  <el-input v-model="formData.fcasecode" name="fcasecode" clearable />
</el-form-item>
    <div class="flex justify-end">
      <el-button type="primary" @click="submitForm(form)">{{ $t('system.confirm') }}</el-button>
    </div>
  </el-form>
</template>

<script lang="ts" setup>
import { useCreate } from '/admin/composables/curd/useCreate'
import { useShow } from '/admin/composables/curd/useShow'
import { onMounted } from 'vue'

const props = defineProps({
  primary: String | Number,
  api: String,
})

const { formData, form, loading, submitForm, close } = useCreate(props.api, props.primary)

if (props.primary) {
  useShow(props.api, props.primary, formData)
}

const emit = defineEmits(['close'])
onMounted(() => {
  close(() => emit('close'))
})
</script>
